$(document).ready(function() {

	//获取主题
	if (window.localStorage) {
		var theme = localStorage["theme"]; //获取theme的值
		changeTheme(theme); //改变主题
	} else {
		$("body").css("background", "#FFF");
	}

});

//弹出皮肤选择器
$(".change-them").click(function() {
	$('.them').slideToggle("slow");
});
$(document).bind("click", function(e) {
	var target = $(e.target);
	/*.closest()沿 DOM 树向上遍历，直到找到已应用选择器的一个匹配为止，返回包含零个或一个元素的 jQuery 对象。*/
	if (target.closest(".them,.change-them").length == 0) {
		$('.them').slideUp('slow');
	};
	e.stopPropagation();
})
$(".them-close").bind("click", function() {
	$('.them').slideUp('slow');
});

//改变主题
function changeTheme(theme) {

	if (theme != null && theme != '') {
		if (theme == 't1') {
			$("body").css("background", "#E0E0E0");
		} else if (theme == 't2') {
			$("body").css("background", "#008080");
		} else if (theme == 't3') {
			$("body").css("background", "#269ABC");
		} else if (theme == 't4') {
			$("body").css("background", "#31B0D5");
		} else {
			$("body").css("background", "#FFF");
		}
	}
	setTheme(theme); //设置主题
}

//设置主题方法
function setTheme(value) {
	if (window.localStorage) {
		localStorage["theme"] = value; //设置theme为"red"
	} else {
		alert('您的浏览器不支持设置主题！！！');
	}
}

//tab切换菜单
$("#tab-meun li").each(function(index) {
	var liNode = $(this);
	liNode.click(function() {
		$("div .con-visible").removeClass("con-visible")
		$("#tab-meun li.click-li").removeClass("click-li");
		$("div .content").eq(index).addClass("con-visible");
		liNode.addClass("click-li");
	});
});